package com.thoughtworks.preuniversity.biblioteca;


import java.util.ArrayList;
import java.util.List;

/**
 * Created by padmavb on 6/12/14.
 */

//Job: Direct all the remaining classes
public  class Application {



    public final List<Object> menuItems=new ArrayList<Object>(){{
        
        add(new ListBooksMovies("List Books"));
        add(new ListBooksMovies("List Movies"));
        add(new Quit());
        add(new CheckOutBook());
        add(new ReturnBook());
            
        }
    };
    private boolean varToContinue=true;

    public  static void main(String [] args){


        Application application=new Application();
        Library library=new Library();

        Menu menu=new Menu(application.menuItems);
        UserInterface userInterface=new UserInterface();
        userInterface.displayWelcome("WELCOME TO BIBLIOTECA\n");


        while (application.varToContinue){

            menu.displayAvailableMenuItems();

            userInterface.displayMessage("Enter your option");

            int userChoice=userInterface.readUserChoice();

            if(menu.validateInputOption(userChoice)){

                 Object ob= menu.getCorrespondingObject(userChoice);
                ((MenuOperation) ob).doCorrespondingOperation(library);

            }
            else
                userInterface.displayMessage("Enter a valid input");
        }


    }



    private class Quit extends MenuOperation{

        @Override
        void doCorrespondingOperation(Library library) {

            varToContinue=false;
        }

        @Override
        String giveJobOfClass() {
            return "Quit";
        }

    }

}
